.class public final Llt/farmis/libraries/shape_import_android/utils/WktUtils;
.super Ljava/lang/Object;
.source "WktUtils.kt"


# annotations
.annotation system Ldalvik/annotation/SourceDebugExtension;
    value = "SMAP\nWktUtils.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WktUtils.kt\nlt/farmis/libraries/shape_import_android/utils/WktUtils\n+ 2 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,227:1\n221#1,6:228\n221#1,6:234\n9700#2,2:240\n*E\n*S KotlinDebug\n*F\n+ 1 WktUtils.kt\nlt/farmis/libraries/shape_import_android/utils/WktUtils\n*L\n129#1,6:228\n149#1,6:234\n204#1,2:240\n*E\n"
.end annotation


# static fields
.field public static final INSTANCE:Llt/farmis/libraries/shape_import_android/utils/WktUtils;

.field private static final PATTERN_INVALID_SIGN_REMOVAL:Ljava/util/regex/Pattern;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .line 18
    new-instance v0, Llt/farmis/libraries/shape_import_android/utils/WktUtils;

    invoke-direct {v0}, Llt/farmis/libraries/shape_import_android/utils/WktUtils;-><init>()V

    return-void
.end method

.method private constructor <init>()V
    .locals 1

    .line 18
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    sput-object p0, Llt/farmis/libraries/shape_import_android/utils/WktUtils;->INSTANCE:Llt/farmis/libraries/shape_import_android/utils/WktUtils;

    const-string v0, "(?=([^\\s0-9-.}{();:,]{1}([0-9]{1,3})[^\\s0-9]{1}\\d{1,}))([^0-9])"

    .line 50
    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    if-eqz v0, :cond_0

    sput-object v0, Llt/farmis/libraries/shape_import_android/utils/WktUtils;->PATTERN_INVALID_SIGN_REMOVAL:Ljava/util/regex/Pattern;

    return-void

    :cond_0
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V

    const/4 v0, 0x0

    throw v0
.end method


# virtual methods
.method public final getWKT2Points(Ljava/lang/String;)Ljava/util/List;
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/List<",
            "Llt/farmis/libraries/shape_import_android/intefaces/LatLngInterface;",
            ">;"
        }
    .end annotation

    const-string v0, "wkt"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const/4 v0, 0x1

    .line 165
    invoke-virtual {p0, p1, v0}, Llt/farmis/libraries/shape_import_android/utils/WktUtils;->getWKT2Points(Ljava/lang/String;Z)Ljava/util/List;

    move-result-object p1

    return-object p1
.end method

.method public final getWKT2Points(Ljava/lang/String;Z)Ljava/util/List;
    .locals 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Z)",
            "Ljava/util/List<",
            "Llt/farmis/libraries/shape_import_android/intefaces/LatLngInterface;",
            ">;"
        }
    .end annotation

    const/4 v0, 0x0

    if-eqz p1, :cond_6

    .line 177
    invoke-interface {p1}, Ljava/lang/CharSequence;->length()I

    move-result v1

    const/4 v2, 0x0

    const/4 v3, 0x1

    if-nez v1, :cond_0

    const/4 v1, 0x1

    goto :goto_0

    :cond_0
    const/4 v1, 0x0

    :goto_0
    if-eqz v1, :cond_1

    goto :goto_3

    :cond_1
    if-eqz p2, :cond_2

    .line 183
    invoke-virtual {p0, p1}, Llt/farmis/libraries/shape_import_android/utils/WktUtils;->removeInvalidWktSymbols(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    .line 186
    :cond_2
    new-instance p2, Ljava/util/ArrayList;

    invoke-direct {p2}, Ljava/util/ArrayList;-><init>()V

    .line 187
    new-instance v1, Lcom/vividsolutions/jts/io/WKTReader;

    invoke-direct {v1}, Lcom/vividsolutions/jts/io/WKTReader;-><init>()V

    .line 190
    :try_start_0
    invoke-virtual {v1, p1}, Lcom/vividsolutions/jts/io/WKTReader;->read(Ljava/lang/String;)Lcom/vividsolutions/jts/geom/Geometry;

    move-result-object p1
    :try_end_0
    .catch Lcom/vividsolutions/jts/io/ParseException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    if-eqz p1, :cond_5

    .line 203
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Geometry;->getCoordinate()Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v0

    if-eqz v0, :cond_3

    .line 204
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Geometry;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p1

    const/4 v0, 0x0

    .line 240
    :goto_1
    array-length v1, p1

    if-ge v0, v1, :cond_3

    aget-object v1, p1, v0

    .line 205
    new-instance v4, Llt/farmis/libraries/shape_import_android/models/ShapeLatLng;

    iget-wide v5, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    iget-wide v7, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    invoke-direct {v4, v5, v6, v7, v8}, Llt/farmis/libraries/shape_import_android/models/ShapeLatLng;-><init>(DD)V

    invoke-virtual {p2, v4}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    add-int/lit8 v0, v0, 0x1

    goto :goto_1

    .line 210
    :cond_3
    invoke-virtual {p2}, Ljava/util/ArrayList;->size()I

    move-result p1

    const/4 v0, 0x2

    if-le p1, v0, :cond_4

    .line 211
    :goto_2
    invoke-virtual {p2, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object p1

    check-cast p1, Llt/farmis/libraries/shape_import_android/intefaces/LatLngInterface;

    invoke-virtual {p2}, Ljava/util/ArrayList;->size()I

    move-result v0

    sub-int/2addr v0, v3

    invoke-virtual {p2, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Llt/farmis/libraries/shape_import_android/intefaces/LatLngInterface;

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result p1

    if-eqz p1, :cond_4

    .line 213
    invoke-virtual {p2}, Ljava/util/ArrayList;->size()I

    move-result p1

    sub-int/2addr p1, v3

    invoke-virtual {p2, p1}, Ljava/util/ArrayList;->remove(I)Ljava/lang/Object;

    goto :goto_2

    :cond_4
    return-object p2

    .line 203
    :cond_5
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V

    throw v0

    :catch_0
    :cond_6
    :goto_3
    return-object v0
.end method

.method public final removeInvalidWktSymbols(Ljava/lang/String;)Ljava/lang/String;
    .locals 13

    const-string v0, "original"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 91
    sget-object v0, Llt/farmis/libraries/shape_import_android/utils/WktUtils;->PATTERN_INVALID_SIGN_REMOVAL:Ljava/util/regex/Pattern;

    invoke-virtual {v0, p1}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object p1

    const-string v0, "-"

    invoke-virtual {p1, v0}, Ljava/util/regex/Matcher;->replaceAll(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    const-string p1, "PATTERN_INVALID_SIGN_REM\u2026rocessed).replaceAll(\"-\")"

    invoke-static {v1, p1}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v2, "\u2013"

    const-string v3, "-"

    const/4 v4, 0x0

    const/4 v5, 0x4

    const/4 v6, 0x0

    .line 92
    invoke-static/range {v1 .. v6}, Lkotlin/text/StringsKt;->replace$default(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    const-string v8, "\u2212"

    const-string v9, "-"

    const/4 v10, 0x0

    const/4 v11, 0x4

    const/4 v12, 0x0

    .line 93
    invoke-static/range {v7 .. v12}, Lkotlin/text/StringsKt;->replace$default(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;

    move-result-object p1

    return-object p1
.end method
